<template>
	<view class="columnbox wdh-100 content">
		<view class="w-box def-bgcol columnbox color-box">
			<picker @change="dateChange" mode="date" fields="month" :end="curDate">
				<view class="rowbox d-box">
					<text style="margin-right: 10rpx;">{{y}}年{{m}}月</text>
					<u-icon name="arrow-down-fill" size="20rpx"></u-icon>
				</view>
			</picker>
			<view class="money-num">{{price}}<text>元</text> </view>
			<view class="w-title">本月已入账薪酬</view>
			<view class="rowbox tx-box" @click="showAccount">提现账户</view>
		</view>
		<!--  <view class="one-info rowbox spb wdh-100">
            <view class="rowbox">
                <image src="../../static/img/kf.svg" mode="widthFix"></image>
                待入账薪酬
            </view>
            <u-icon name="arrow-right" size="28rpx"></u-icon>
        </view> -->
		<view class="one-info rowbox spb wdh-100" @click="showNowSalary">
			<view class="rowbox">
				<image src="../../static/img/kf.svg" mode="widthFix"></image>
				可提现薪酬
			</view>
			<u-icon name="arrow-right" size="28rpx"></u-icon>
		</view>
		<view class="wdh-100 detail-title">{{y}}年{{m*1}}月薪酬明细</view>
		<view @click="showDetail" class="r-box rowbox spb" v-for="(item,index) in list" :key='index'>
			<view class="columnbox u-info">
				<view class="rowbox wdh-100 spb">
					<view class="u-name">{{item.title}}</view>
					<!-- 	<view class="status-w" v-if="item.status==2">问诊中</view>
					<view class="status-w" v-else-if="item.status==3" style="color: #eb262a ;">已退款</view>
					<view class="status-w" v-else-if="item.status==4" style="color: #595959 ;">问诊结束</view> -->
				</view>
				<view class="rowbox wdh-100 spb t-box">
					<!-- <view>专家咨询</view> -->
					<view>{{getAddtime(item.addtime)}}</view>
				</view>
			</view>
			<view v-if="item.status==1" class="rowbox" style="font-size: 28rpx;color: #f10000 ;">
				+{{item.price}}
			</view>
			<view v-else class="rowbox" style="font-size: 28rpx;">
				+{{item.price}}
			</view>
		</view>
	</view>
</template>

<script>
	import getDate from '@/utils/time.js'
	export default {
		data() {
			return {
				price: 0,
				month: '',
				year: '',
				pageNo: 1,
				inttime: 0,
				endtime: 0,
				y: '',
				m: '',
				list: [],
				total: 0,
				statisticsInfo: {
					wwcnum: 0,
					wcnum: 0
				},
				curDate: ''
			}
		},
		onLoad() {
			let date = new Date()
			this.year = date.getFullYear()
			this.month = date.getMonth() + 1
			this.getInfo()
			this.getList()

			let y = date.getFullYear()
			this.y = y
			let m = date.getMonth() < 9 ? '0' + (date.getMonth() + 1) : (date.getMonth() + 1)
			this.m = m
			this.curDate = y + '-' + m
			this.getDateRange()

		},
		computed: {
			user() {
				return this.$store.state.user
			},
			isLogin() {
				return this.$store.state.isLogin
			}
		},
		onReachBottom() {
			if (this.list < this.total) {
				this.pageNo++
				this.getList()
			}
		},
		methods: {
			dateChange(e) {
				this.y = e.detail.value.split('-')[0]
				this.m = e.detail.value.split('-')[1]
				this.year = this.y * 1
				this.month = this.m * 1
				this.getInfo()
				this.getDateRange()
			},
			getAddtime(v) {
				return getDate.toLocalDate(v)
			},
			getDateRange() {
				var date = new Date();
				date.setFullYear(this.y)
				date.setMonth(this.m * 1 - 1)
				date.setDate(1);
				var firstDay = date.toLocaleDateString();
				this.inttime = Date.parse(firstDay) / 1000
				var date = new Date();
				date.setFullYear(this.y)
				date.setMonth(this.m * 1);
				date.setDate(0);
				var lastDay = date.toLocaleDateString();
				console.log(firstDay, lastDay);
				this.endtime = Date.parse(lastDay) / 1000
				this.pageNo = 1
				this.list = []
				this.getList()
			},
			getList() {
				this.$req.post('/doctor/xinchou', {
					pageNo: this.pageNo,
					pageSize: 20,
					inttime: this.inttime,
					endtime: this.endtime,
					doctorid: uni.getStorageSync('uid')
				}).then(res => {
					this.list = this.list.concat(res.data.data.data)
					this.total = res.data.data.totalCount
					this.statisticsInfo = res.data.data
				})
			},
			getInfo() {
				this.$req.post('/doctor/doctorprice', {
					doctorid: uni.getStorageSync('uid'),
					month: this.month,
					year: this.year
				}).then(res => {
					console.log(res)
					this.price = res.data.data
				})
			},
			showAccount() {
				uni.navigateTo({
					url: '/pages/wallet/withdrawAccount'
				})
			},
			showNowSalary() {
				uni.navigateTo({
					url: '/pages/wallet/nowSalary'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		min-height: 100vh;
		background: #F5F8FB;
		justify-content: flex-start;
	}

	.color-box {
		width: 710rpx;
		padding: 40rpx 20rpx;
		border-radius: 20rpx;
		margin: 20rpx 0;
		position: relative;

		.tx-box {
			position: absolute;
			right: 0;
			top: 40rpx;
			background: rgba(#fff, .4);
			font-size: 24rpx;
			padding: 10rpx 20rpx;
			border-radius: 100rpx 0 0 100rpx;
			padding-right: 0;
			color: #fff;
		}

		.d-box {
			font-size: 24rpx;
			background: rgba(#fff, .9);
			padding: 10rpx 20rpx;
			border-radius: 100rpx;
			transform: scale(.9);
		}

		.money-num {
			margin-top: 20rpx;
			color: #fff;
			font-size: 50rpx;
			font-weight: bold;

			text {
				font-weight: normal;
				font-size: 28rpx;
				margin-left: 10rpx;
			}
		}

		.w-title {
			color: #fff;
			font-size: 24rpx;
			margin-top: 20rpx;
		}
	}

	.one-info {
		background: #fff;
		padding: 26rpx 40rpx;
		font-size: 28rpx;
		color: #656767;
		border-bottom: #F5F8FB solid 1px;

		image {
			width: 50rpx;
			height: 50rpx;
			margin-right: 20rpx;
		}
	}

	.detail-title {
		color: #adadad;
		font-size: 24rpx;
		padding: 20rpx 20rpx;
		box-sizing: border-box;
	}

	.r-box {
		background: #fff;
		padding: 32rpx 32rpx;
		width: 100%;
		margin-bottom: 2rpx;
	}

	.u-info {
		width: calc(100% - 120rpx);
	}

	.u-name {
		color: #656767;
		font-size: 32rpx;
	}

	.t-box {
		font-size: 28rpx;
		margin-top: 20rpx;
	}
</style>